const allowed="abc"
const words=['abccc','abcc','aadc','aabbcc'];

function fun(allowed:string,words:string[]){
    let num=0
    let newall=allowed.split('');
    for(let i=0;i<words.length;i++){
        let num2=0
        let newword=words[i].split('')
        for(let j=0;j<newword.length;j++){
            if(newall.includes(newword[j])){
                num2++;
            }
        }
        if(num2==newword.length){
            num++
        }
    }
    return num
}

console.log(fun(allowed,words))

//股票
let Max=function(price:number[]){
    let num=0;
    for(let i=0;i<price.length-1;i++){
        num+=Math.max(price[i+1]-price[i],0)
    }
    return num
}

console.log(Max([9,1,5,3,6,5]))

//2转1
let newBrr:Array<number>=[]
function fun4(arr:Array<Array<number> | number>){
    
    arr.forEach((item)=>{
        if(Array.isArray(item)){
            fun4(item)
        }else{
            newBrr.push(item)
        }
    })
    return newBrr
}

console.log(fun4([[1,2,3,5],[6,8],5]))

//出现一次元素
function fun5(arr:number[]){
    
    for(let i=0;i<arr.length;i++)
    {
        let num=0;
        let index=0;
        for(let j=1;j<arr.length;j++){
            if(arr[i]==arr[j])
            {
                num++;
                index=arr[j]
            }
        }
        if(num==1){
            return index
        }
    }
    
}

console.log(fun5([1,1,1,5,5,3]))